package com.hunktimes.wholesale.ui.main

import android.os.Bundle
import android.view.View
import androidx.navigation.Navigation
import androidx.navigation.ui.setupWithNavController
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.hunktimes.wholesale.R
import com.hunktimes.wholesale.base.BaseRootFragment
import com.hunktimes.wholesale.databinding.FragmentMainBinding
import com.hunktimes.wholesale.extension.setupWithNavControllerV2

/**
 * Author: Delete
 * Date: 2020/7/22 15:58
 * Description:
 *
 */
class MainFragment : BaseRootFragment(R.layout.fragment_main) {
    lateinit var viewBinding: FragmentMainBinding

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        viewBinding = FragmentMainBinding.bind(view)

        val navView: BottomNavigationView = viewBinding.navView

        val navController = Navigation.findNavController(requireActivity(), R.id.nav_main_fragment)

        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        //同步 tab title 和 appBar title
//        val appBarConfiguration = AppBarConfiguration(
//            setOf(
//                R.id.navigation_home,R.id.navigation_category,
//                R.id.navigation_cart, R.id.navigation_me
//            )
//        )
//        setupActionBarWithNavController(
//            requireActivity() as AppCompatActivity,
//            navController,
//            appBarConfiguration
//        )

        navView.setupWithNavController(navController)

        //拦截 tab 切换 登录
//        navView.setupWithNavControllerV2(navController, R.id.navigation_me) {
//            rootNavController.navigate(R.id.navigation_login)
//        }


    }
}